package com.jia.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jia.product.entity.SpuImages;
import com.jia.product.mapper.SpuImagesMapper;
import com.jia.product.service.SpuImagesService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * spu图片(SpuImages)表服务实现类
 *
 * @author makejava
 * @since 2025-07-08 18:15:28
 */
@Service("spuImagesService")
public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesMapper, SpuImages>
        implements SpuImagesService {

    @Override
    public void saveBaseImages(Long spuInfoId, List<String> images) {
        if (CollectionUtils.isEmpty(images)) {

        } else {
            List<SpuImages> collect = images.stream().map(image -> {
                SpuImages spuImages = new SpuImages();
                spuImages.setSpuId(spuInfoId);
                spuImages.setImgUrl(image);
                return spuImages;
            }).collect(Collectors.toList());
            this.saveBatch(collect);
        }
    }

}

